package com.doordu.web;

import com.netflix.appinfo.ApplicationInfoManager;
import com.netflix.appinfo.DataCenterInfo;
import com.netflix.appinfo.EurekaInstanceConfig;
import com.netflix.discovery.DiscoveryManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.netflix.eureka.serviceregistry.EurekaRegistration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author zxw
 * @date 2020/8/20 14:15
 */
@RestController
@RequestMapping("/eureka")
public class EurekaController {
    @Autowired
    private EurekaRegistration eurekaRegistration;

    @RequestMapping(value = "/offline", method = RequestMethod.GET)
    public void offLine() {
        ApplicationInfoManager infoManager = eurekaRegistration.getApplicationInfoManager();
        infoManager = new ApplicationInfoManager(new EurekaInstanceConfig() {
            @Override
            public String getInstanceId() {
                return null;
            }

            @Override
            public String getAppname() {
                return null;
            }

            @Override
            public String getAppGroupName() {
                return null;
            }

            @Override
            public boolean isInstanceEnabledOnit() {
                return false;
            }

            @Override
            public int getNonSecurePort() {
                return 0;
            }

            @Override
            public int getSecurePort() {
                return 0;
            }

            @Override
            public boolean isNonSecurePortEnabled() {
                return false;
            }

            @Override
            public boolean getSecurePortEnabled() {
                return false;
            }

            @Override
            public int getLeaseRenewalIntervalInSeconds() {
                return 0;
            }

            @Override
            public int getLeaseExpirationDurationInSeconds() {
                return 0;
            }

            @Override
            public String getVirtualHostName() {
                return null;
            }

            @Override
            public String getSecureVirtualHostName() {
                return null;
            }

            @Override
            public String getASGName() {
                return null;
            }

            @Override
            public String getHostName(boolean refresh) {
                return null;
            }

            @Override
            public Map<String, String> getMetadataMap() {
                return null;
            }

            @Override
            public DataCenterInfo getDataCenterInfo() {
                return null;
            }

            @Override
            public String getIpAddress() {
                return null;
            }

            @Override
            public String getStatusPageUrlPath() {
                return null;
            }

            @Override
            public String getStatusPageUrl() {
                return null;
            }

            @Override
            public String getHomePageUrlPath() {
                return null;
            }

            @Override
            public String getHomePageUrl() {
                return null;
            }

            @Override
            public String getHealthCheckUrlPath() {
                return null;
            }

            @Override
            public String getHealthCheckUrl() {
                return null;
            }

            @Override
            public String getSecureHealthCheckUrl() {
                return null;
            }

            @Override
            public String[] getDefaultAddressResolutionOrder() {
                return new String[0];
            }

            @Override
            public String getNamespace() {
                return null;
            }
        });
        DiscoveryManager.getInstance().shutdownComponent();
    }
}
